import React from 'react';
import {Icon} from 'weaver-mobile';
import { getLabel } from '../../util/common';
export default class SecondAuthInfo extends React.Component {
    constructor(props) {
        super(props);
    }

    getMsgContent() {
        const msgContent = [];
        const {msgtype, detail} = this.props;
        if (msgtype == "0") {
            msgContent.push(<span>{detail}</span>);
        } else if (msgtype == "2") {
            msgContent.push(<span>{getLabel(514319, "保护数据被篡改")}！</span>);
            msgContent.push(<a href="javascript:void(0);" onClick={this.openAuthDetail.bind(this)}>{getLabel(512307, "查看详情")}</a>);
        }

        return msgContent;
    }

    openAuthDetail() {
        this.props.openAuthDetail();
    }

    render() {
        const {msgtype} = this.props;
        if (msgtype != "0" && msgtype != "2") {
            return <div/>
        } else {
            return (
                <div className="secondauth-error-msg">
                    <div className="secondauth-error-msg-icon">
                        <Icon type="warning"/>
                    </div>
                    <div className="secondauth-error-msg-detail">
                        {this.getMsgContent()}
                    </div>
                </div>
            )
        }
    }
}